package com.shenzw.mybatisdemo.controller;

import com.shenzw.mybatisdemo.controller.response.DeptResponseMore;
import com.shenzw.mybatisdemo.controller.response.EmployeeResponseOne;
import com.shenzw.mybatisdemo.domain.Dept;
import com.shenzw.mybatisdemo.service.DeptService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author shenzw
 * @date 2023/11/30
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/dept")
public class DeptController {

    private final DeptService deptService;

    @GetMapping("/getDeptInfo")
    public List<DeptResponseMore> getDeptInfo(@RequestParam Integer deptId) {
        return deptService.getDeptInfo(deptId);
    }

    @GetMapping("/getEmploy")
    public List<EmployeeResponseOne> getEmploy(@RequestParam Integer id) {
        return deptService.getEmploy(id);
    }

    @GetMapping("/selectDeptByName")
    public List<Dept> selectDeptByName(@RequestParam String deptName) {
        return deptService.selectDeptByName(deptName);
    }

    @GetMapping("/selectDeptById")
    public Dept selectDeptById(@RequestParam Integer id) {
        return deptService.selectDeptById(id);
    }
}
